#ifndef __GRAPH_WINDOW_H__
#define __GRAPH_WINDOW_H__

#include <GL/glut.h>

#include "glutMaster.h"

#include "Net.h"
#include "Frame.h"
#include "Cylinder.h"
#include "Sphere.h"

#include "SimpleMbsRenderer.h"
#include "ObjectMbsRenderer.h"

#include <list>

//-----------------------------------------------------------------------------
// RSIM includes:
//-----------------------------------------------------------------------------
#include "RSIM_INC.h"
//-----------------------------------------------------------------------------

/**
 * @class GraphWindow
 * @brief Basic viewing window for the RSIM visualization
 * @author Tomasz Rudny (rudnyt@gmail.com)
 * @version 1.1
 * @date 28.09.2011
 */

using namespace RSIM;

namespace graph {

class GraphWindow : public GlutWindow{
public:

   int          height, width;
   int          initPositionX, initPositionY;

   float view_rotx, view_roty, view_rotz;
   float sx, sy, sz;

   int prevMouseX, prevMouseY;
   bool mouseRButtonDown, mouseLButtonDown;
   bool scaleModeOn;
   bool wireframeMode;

   CNet net;
   Frame frame;

   // pointer to a multi body system to be rendered
  // RSIM::MultibodySystem *mbs_;
   MbsRenderer *renderer;

   std::list<MbsRenderer *> renderers;

   GraphWindow(GlutMaster * glutMaster,
              int setWidth, int setHeight,
              int setInitPositionX, int setInitPositionY,
              string title);
   ~GraphWindow();

   void CallBackDisplayFunc(void);
   void CallBackReshapeFunc(int w, int h);
   void CallBackIdleFunc(void);
   void CallBackMotionFunc(int x, int y);
   void CallBackMouseFunc(int button, int state, int x, int y);
   void CallBackKeyboardFunc(unsigned char key, int x, int y);

   void StartSpinning(GlutMaster * glutMaster);

   //--------------------------------------------------------------------------
   void setMBS(RSIM::MultibodySystem *mbs);
   void addMBS(RSIM::MultibodySystem *mbs);
   void addMBS(RSIM::MultibodySystem * mbs,
   		std::string model_files[], int modelFileCount,
   		int modelAssignments[]);
   void clearMBS();

   void tempMethod1(double shiftX, double shiftZ);

private:
   void setLights();

 };

}
#endif /* GRAPHWINDOW_H_ */
